#include "asm.h"
#include "regdef.h"
#include "inst_test.h"

LEAF(n43_ld_bu_test)
    
    addi.w s0, s0 ,1
    li  s2, 0x0
###test inst
    TEST_LD_BU(0x79dbf0ff, 0xd5498, 0x0000408, 0x0000408, 0x000000ff)
    TEST_LD_BU(0x9b5bab6c, 0xd4430, 0x000052e, 0x000052c, 0x0000005b)
    TEST_LD_BU(0xd156f470, 0xd45d8, 0x000060b, 0x0000608, 0x000000d1)
    TEST_LD_BU(0x4d8564c0, 0xdabac, 0x0000180, 0x0000180, 0x000000c0)
    TEST_LD_BU(0x927c9930, 0xdae00, 0x0000a28, 0x0000a28, 0x00000030)
    TEST_LD_BU(0x9ec5966a, 0xd72b8, 0x0000e9c, 0x0000e9c, 0x0000006a)
    TEST_LD_BU(0x13f91e58, 0xd1f30, 0x0000600, 0x0000600, 0x00000058)
    TEST_LD_BU(0x0249eebd, 0xd3d28, 0x0000e74, 0x0000e74, 0x000000bd)
    TEST_LD_BU(0x4d40dd0e, 0xd2c50, 0x00002d2, 0x00002d0, 0x00000040)
    TEST_LD_BU(0x1dd043a8, 0xd6a7c, 0x00000f8, 0x00000f8, 0x000000a8)
    TEST_LD_BU(0xed111118, 0xd42b4, 0x0000b60, 0x0000b60, 0x00000018)
    TEST_LD_BU(0x6937c000, 0xde7f0, 0x0000749, 0x0000748, 0x000000c0)
    TEST_LD_BU(0xe4f76a00, 0xda130, 0x0000768, 0x0000768, 0x00000000)
    TEST_LD_BU(0xee33dcd0, 0xdbc2c, 0x0000868, 0x0000868, 0x000000d0)
    TEST_LD_BU(0xa6a67232, 0xd8b40, 0x0000f07, 0x0000f04, 0x000000a6)
    TEST_LD_BU(0x2c62e6d4, 0xd3cd4, 0x0000270, 0x0000270, 0x000000d4)
    TEST_LD_BU(0xdbe75a30, 0xd2854, 0x0000666, 0x0000664, 0x000000e7)
    TEST_LD_BU(0xd2201348, 0xd8b40, 0x0000bc1, 0x0000bc0, 0x00000013)
    TEST_LD_BU(0xbc509f3c, 0xd0910, 0x00001c3, 0x00001c0, 0x000000bc)
    TEST_LD_BU(0xd03bb99a, 0xd2a84, 0x0000780, 0x0000780, 0x0000009a)
    TEST_LD_BU(0xc1da3a60, 0xd91c0, 0x00004d0, 0x00004d0, 0x00000060)
    TEST_LD_BU(0x2c56dcf0, 0xd6094, 0x0000c86, 0x0000c84, 0x00000056)
    TEST_LD_BU(0xf4a53d22, 0xd0384, 0x0000326, 0x0000324, 0x000000a5)
    TEST_LD_BU(0x44b66444, 0xd9c48, 0x0000580, 0x0000580, 0x00000044)
    TEST_LD_BU(0x2982f7ac, 0xd0a18, 0x0000208, 0x0000208, 0x000000ac)
    TEST_LD_BU(0x90895498, 0xd6210, 0x000059c, 0x000059c, 0x00000098)
    TEST_LD_BU(0x71d04400, 0xd1d08, 0x0000faf, 0x0000fac, 0x00000071)
    TEST_LD_BU(0x244f2870, 0xd1f50, 0x00004c9, 0x00004c8, 0x00000028)
    TEST_LD_BU(0x60bdb8c0, 0xd60e0, 0x0000944, 0x0000944, 0x000000c0)
    TEST_LD_BU(0x952b094a, 0xd4a94, 0x0000700, 0x0000700, 0x0000004a)
    TEST_LD_BU(0x407a8b80, 0xdbb68, 0x0000d78, 0x0000d78, 0x00000080)
    TEST_LD_BU(0x1ca93e6d, 0xd0c60, 0x0000e14, 0x0000e14, 0x0000006d)
    TEST_LD_BU(0xcbb35de0, 0xd2358, 0x00004e0, 0x00004e0, 0x000000e0)
    TEST_LD_BU(0x8bc60e3a, 0xd2aa0, 0x000054a, 0x0000548, 0x000000c6)
    TEST_LD_BU(0x95020f1e, 0xd2008, 0x000020d, 0x000020c, 0x0000000f)
    TEST_LD_BU(0x4c6082f4, 0xd29e8, 0x00009ec, 0x00009ec, 0x000000f4)
    TEST_LD_BU(0xe8c29c44, 0xd41e4, 0x00000ca, 0x00000c8, 0x000000c2)
    TEST_LD_BU(0x7dd89185, 0xdc0a8, 0x0000184, 0x0000184, 0x00000085)
    TEST_LD_BU(0xf2ef2428, 0xd4478, 0x00005bc, 0x00005bc, 0x00000028)
    TEST_LD_BU(0x2789e735, 0xd8088, 0x000087c, 0x000087c, 0x00000035)
    TEST_LD_BU(0x57613900, 0xd6434, 0x00000c8, 0x00000c8, 0x00000000)
    TEST_LD_BU(0xf831d258, 0xdb5f0, 0x00002cc, 0x00002cc, 0x00000058)
    TEST_LD_BU(0x94768ba0, 0xd9ef8, 0x0000d84, 0x0000d84, 0x000000a0)
    TEST_LD_BU(0x6f5ab393, 0xd23d0, 0x00001b8, 0x00001b8, 0x00000093)
    TEST_LD_BU(0xd73483da, 0xd7a70, 0x0000009, 0x0000008, 0x00000083)
    TEST_LD_BU(0x4ab1c5a6, 0xd6ea8, 0x00001a0, 0x00001a0, 0x000000a6)
    TEST_LD_BU(0xd4b6c948, 0xd5864, 0x0000d0f, 0x0000d0c, 0x000000d4)
    TEST_LD_BU(0x1b189c1c, 0xd2564, 0x000017e, 0x000017c, 0x00000018)
    TEST_LD_BU(0x861b3d98, 0xd5df8, 0x00009a0, 0x00009a0, 0x00000098)
    TEST_LD_BU(0x1f876f58, 0xd10e0, 0x00006bc, 0x00006bc, 0x00000058)
    TEST_LD_BU(0x3b207858, 0xd14a4, 0x0000cf6, 0x0000cf4, 0x00000020)
    TEST_LD_BU(0x67c1dd18, 0xdd370, 0x0000326, 0x0000324, 0x000000c1)
    TEST_LD_BU(0x706669a8, 0xd23dc, 0x0000fb0, 0x0000fb0, 0x000000a8)
    TEST_LD_BU(0x0e4383c0, 0xd0000, 0x00004a9, 0x00004a8, 0x00000083)
    TEST_LD_BU(0xd9c861cc, 0xd0000, 0x0000d3e, 0x0000d3c, 0x000000c8)
    TEST_LD_BU(0xfecf79cc, 0xd0000, 0x0000c20, 0x0000c20, 0x000000cc)
    TEST_LD_BU(0x62eab940, 0xd0000, 0x0000fe1, 0x0000fe0, 0x000000b9)
    TEST_LD_BU(0xc5f71c93, 0xd0000, 0x00003ac, 0x00003ac, 0x00000093)
    TEST_LD_BU(0xdc990bc0, 0xd0000, 0x0000632, 0x0000630, 0x00000099)
    TEST_LD_BU(0xffa821b0, 0xd0000, 0x000047a, 0x0000478, 0x000000a8)
    TEST_LD_BU(0x669cb8f8, 0xd0000, 0x0000dc8, 0x0000dc8, 0x000000f8)
    TEST_LD_BU(0xd9650b98, 0xd0000, 0x0000202, 0x0000200, 0x00000065)
    TEST_LD_BU(0x845c79fc, 0xd0000, 0x0000504, 0x0000504, 0x000000fc)
    TEST_LD_BU(0xa7ed9420, 0xd0000, 0x00005e8, 0x00005e8, 0x00000020)
    TEST_LD_BU(0xa458f1f2, 0xd0000, 0x0000125, 0x0000124, 0x000000f1)
    TEST_LD_BU(0xad33ad20, 0xd0000, 0x0000b1a, 0x0000b18, 0x00000033)
    TEST_LD_BU(0xbd743318, 0xd0000, 0x00002f8, 0x00002f8, 0x00000018)
    TEST_LD_BU(0xec315702, 0xd0000, 0x0000230, 0x0000230, 0x00000002)
    TEST_LD_BU(0x7b433429, 0xd0000, 0x0000ae0, 0x0000ae0, 0x00000029)
    TEST_LD_BU(0x345592f0, 0xd0000, 0x0000080, 0x0000080, 0x000000f0)
    TEST_LD_BU(0x15fec970, 0xd0000, 0x00006d0, 0x00006d0, 0x00000070)
    TEST_LD_BU(0x483ec7ee, 0xd0000, 0x0000570, 0x0000570, 0x000000ee)
    TEST_LD_BU(0xca82fc00, 0xd0000, 0x0000cfe, 0x0000cfc, 0x00000082)
    TEST_LD_BU(0x25953f20, 0xd0000, 0x00000c3, 0x00000c0, 0x00000025)
    TEST_LD_BU(0xc7184dde, 0xd0000, 0x0000558, 0x0000558, 0x000000de)
    TEST_LD_BU(0x899be100, 0xd0000, 0x00000c4, 0x00000c4, 0x00000000)
    TEST_LD_BU(0x4629ad14, 0xd0000, 0x0000550, 0x0000550, 0x00000014)
    TEST_LD_BU(0xb741c3b2, 0xd0000, 0x0000370, 0x0000370, 0x000000b2)
    TEST_LD_BU(0x3b7a8198, 0xd0000, 0x0000dc5, 0x0000dc4, 0x00000081)
    TEST_LD_BU(0xc5e541f6, 0xd0000, 0x0000560, 0x0000560, 0x000000f6)
    TEST_LD_BU(0xdf5b1a0a, 0xd0000, 0x00008c0, 0x00008c0, 0x0000000a)
    TEST_LD_BU(0x9e06fab8, 0xd0000, 0x00004ca, 0x00004c8, 0x00000006)
    TEST_LD_BU(0x70df5f2c, 0xd0000, 0x00006ba, 0x00006b8, 0x000000df)
    TEST_LD_BU(0x5717a104, 0xd0000, 0x0000dc2, 0x0000dc0, 0x00000017)
    TEST_LD_BU(0x91f2f789, 0xd0000, 0x0000f86, 0x0000f84, 0x000000f2)
    TEST_LD_BU(0x48f3e380, 0xd0000, 0x0000b7c, 0x0000b7c, 0x00000080)
    TEST_LD_BU(0x804e0100, 0xd0000, 0x0000e00, 0x0000e00, 0x00000000)
    TEST_LD_BU(0x27635fe4, 0xd0000, 0x00002e0, 0x00002e0, 0x000000e4)
    TEST_LD_BU(0xffcbe970, 0xd0000, 0x00009ae, 0x00009ac, 0x000000cb)
    TEST_LD_BU(0x5a3cef6e, 0xd0000, 0x0000605, 0x0000604, 0x000000ef)
    TEST_LD_BU(0xef7b5e90, 0xd0000, 0x0000896, 0x0000894, 0x0000007b)
    TEST_LD_BU(0x262a5e90, 0xd0000, 0x000096f, 0x000096c, 0x00000026)
    TEST_LD_BU(0xa26701e8, 0xd0000, 0x0000399, 0x0000398, 0x00000001)
    TEST_LD_BU(0x2f2f73f0, 0xd0000, 0x0000a14, 0x0000a14, 0x000000f0)
    TEST_LD_BU(0x38ce4640, 0xd0000, 0x0000782, 0x0000780, 0x000000ce)
    TEST_LD_BU(0xbb69c800, 0xd0000, 0x0000b46, 0x0000b44, 0x00000069)
    TEST_LD_BU(0x7b9da800, 0xd0000, 0x000004a, 0x0000048, 0x0000009d)
    TEST_LD_BU(0x5568c260, 0xd0000, 0x00002e0, 0x00002e0, 0x00000060)
    TEST_LD_BU(0x4bd93c80, 0xd0000, 0x0000e30, 0x0000e30, 0x00000080)
    TEST_LD_BU(0x23adf432, 0xd0000, 0x0000009, 0x0000008, 0x000000f4)
    TEST_LD_BU(0x6187f420, 0xd0000, 0x0000fd4, 0x0000fd4, 0x00000020)
    TEST_LD_BU(0x68363fa0, 0xd0000, 0x0000e68, 0x0000e68, 0x000000a0)
    TEST_LD_BU(0x3723c7f3, 0xd0000, 0x00003e0, 0x00003e0, 0x000000f3)
    TEST_LD_BU(0xd367e11a, 0xd0000, 0x0000000, 0x0000000, 0x0000001a)
    TEST_LD_BU(0xea1bc1e0, 0xd0000, 0x0000003, 0x0000000, 0x000000ea)
    TEST_LD_BU(0x0dbcd2ea, 0xd0000, 0x0000001, 0x0000000, 0x000000d2)
    TEST_LD_BU(0x2e8377c6, 0xd0000, 0x0000000, 0x0000000, 0x000000c6)
    TEST_LD_BU(0x85d1767c, 0xd0000, 0x0000001, 0x0000000, 0x00000076)
    TEST_LD_BU(0x2a807b6e, 0xd0000, 0x0000000, 0x0000000, 0x0000006e)
    TEST_LD_BU(0x7c7e468b, 0xd0000, 0x0000001, 0x0000000, 0x00000046)
    TEST_LD_BU(0x766b30aa, 0xd0000, 0x0000000, 0x0000000, 0x000000aa)
    TEST_LD_BU(0xf3112744, 0xd0000, 0x0000003, 0x0000000, 0x000000f3)
    TEST_LD_BU(0x24da377c, 0xd0000, 0x0000001, 0x0000000, 0x00000037)
    TEST_LD_BU(0x9eda1a30, 0xd0000, 0x0000001, 0x0000000, 0x0000001a)
    TEST_LD_BU(0x1e7730fe, 0xd0000, 0x0000000, 0x0000000, 0x000000fe)
    TEST_LD_BU(0x4acfdea0, 0xd0000, 0x0000001, 0x0000000, 0x000000de)
    TEST_LD_BU(0x84b70109, 0xd0000, 0x0000003, 0x0000000, 0x00000084)
    TEST_LD_BU(0xace9f794, 0xd0000, 0x0000000, 0x0000000, 0x00000094)
    TEST_LD_BU(0x60a3b6d8, 0xd0000, 0x0000001, 0x0000000, 0x000000b6)
    TEST_LD_BU(0x954eb5ee, 0xd0000, 0x0000001, 0x0000000, 0x000000b5)
    TEST_LD_BU(0x95ffcf80, 0xd0000, 0x0000003, 0x0000000, 0x00000095)
    TEST_LD_BU(0xe20efe40, 0xd0000, 0x0000000, 0x0000000, 0x00000040)
    TEST_LD_BU(0x826e0c40, 0xd0000, 0x0000003, 0x0000000, 0x00000082)
    TEST_LD_BU(0x3c7f3796, 0xd0000, 0x0000003, 0x0000000, 0x0000003c)
    TEST_LD_BU(0xd82d4498, 0xd0000, 0x0000002, 0x0000000, 0x0000002d)
    TEST_LD_BU(0x00000000, 0xd0000, 0x0000000, 0x0000000, 0x00000000)
###detect exception
    bne s2, zero, inst_error
    nop
###score ++
    addi.w s3, s3, 1
###output (s0<<24)|s3
inst_error:  
    slli.w t1, s0, 24
    NOP4
    or t0, t1, s3 
    NOP4
    st.w t0, s1, 0
    jirl zero, ra, 0
END(n43_ld_bu_test)
